var frmHeight = getClientHeight();
var frmWidth = getClientWidth();

function getClientHeight(){
	var theHeight;
	if (window.innerHeight)
		theHeight=window.innerHeight;
	else if (document.documentElement && document.documentElement.clientHeight) 
		theHeight=document.documentElement.clientHeight;
	else if (document.body) 
		theHeight=document.body.clientHeight;
	
	return theHeight;
}

function getClientWidth(){
	var theWidth;
	if (window.innerWidth) 
		theWidth=window.innerWidth;
	else if (document.documentElement && document.documentElement.clientWidth) 
		theWidth=document.documentElement.clientWidth;
	else if (document.body) 
		theWidth=document.body.clientWidth;

	return theWidth;
}

function INSPsubmitform(frm,func){
	$.blockUI({ overlayCSS: { backgroundColor: '#E0ECFF' } }); 
    var url = jQuery('#'+frm).attr("action");
    jQuery('#'+frm).form('submit',{
            url:url,
            onSubmit: function(){
                  return $(this).form('validate');
            },
            success:function(data){
				$.unblockUI();
                if (func == undefined ){
                     if (data == "1"){
                        pesan('Data Sudah Disimpan ','Sukses');
                    }else{
                         pesan(data,'Result');
                    }
                }else{
                    func(data);
                }
            },
            error:function(data){
				$.unblockUI();
                 if (func == undefined ){
                     pesan(data,'Error');
                }else{
                    func(data);
                }
            }
    });
}

var divcontainer;
function mywindow(txt,judul,width,height){
    divcontainer = "mywindow"+Math.floor(Math.random()*99999);
    $("<div id='"+divcontainer+"'></div>").appendTo("body");
    divcontainer = "#"+divcontainer;
    $(divcontainer).css({'padding':'10px'});
    $(divcontainer).html(txt);

    if (judul === undefined ) judul ='DATA';
    if (width === undefined ) {
        var wdh = $(divcontainer).outerWidth(true);
        if ( wdh > 750 ) wdh = 750;
        if ( wdh < 250 ) wdh = 250;
        width = wdh ;
    }
    if (height === undefined ){
        var hgt = $(divcontainer).outerHeight(true);
        if ( hgt > 550 ) hgt = 550;
        if ( hgt < 150 ) hgt = 150;
        height = hgt ;
    }
    var leftCenter = window.innerWidth/2;
	var topCenter = window.innerHeight/2;
    var panelLeft = leftCenter - (width/2);
    var panelTop = topCenter - (height/2);
    $(divcontainer).css({'opacity':0});
   $(divcontainer).window({
        title: judul,
        autoOpen: false,
        left:panelLeft,
        top:panelTop,
        width:width,
        height:height,
        modal: true,
        shadow: false,
        closed: false,
		closable: true,
        collapsible:false,
        collapsed:false,
        onBeforeClose:function(){
			$($(divcontainer).window('panel')).animate({
				"width": "-15px",
				"height":"-15px",
				"left":  leftCenter +"px",
				"top": topCenter +"px",
				"opacity":0
			  }, 777,function(){
				  $(divcontainer).html('');
				 
					$($(divcontainer).window('panel')).css({'left':panelLeft+'px','top':panelTop+'px','width':width+'px','height':height+'px'});
					
				   $(divcontainer).window("close",true);
				    $(divcontainer).window("destroy",true);
				  return true;
				  });
			
		},
		onBeforeOpen:function(){
				
			$($(divcontainer).window('panel')).css({'left':leftCenter+'px','top':topCenter+'px','width':'1px','height':'1px'});
		},
		onOpen:function(){
			 $($(divcontainer).window('panel')).animate({
				"width": (width+10)+"px",
				"height":(height+45)+"px",
				"left": panelLeft+"px",
				"top": panelTop+"px",
				'opacity':1
			  }, 000,function(){
				  $(divcontainer).animate({'width':(width-13)+'px','height':(height)+'px','opacity':1}
				  ,000
				  ,function(){
					   //$(divcontainer).window('resize');
					  });
				  });
		}
		
        });
  $(divcontainer).window('open');
   $(divcontainer).window('open');
}

function mywindow_close(){
	$(divcontainer).window('close');
}


function fillCombo(url, SelID, value, value2, value3, value4){
	//if(Ext.get(SelID).innerHTML == "") return false;
	if (value == undefined) value = "";
	if (value2 == undefined) value2 = "";
	if (value3 == undefined) value3 = "";
	if (value4 == undefined) value4 = "";
	
	$.post(url, {"v": value, "v2": value2, "v3": value3, "v4": value4},function(data){
		$('#'+SelID).append(data);
	});

}



		
